
#include <math.h>
#include "GeometricMeanFilter.h"

void
GeometricMeanFilter::help(std::string &buf) const
{
    buf.append("几何均值滤波器;更适合处理高斯噪声,均匀噪声\n");
    Filter::help(buf);
    return ;
}

double
GeometricMeanFilter::operOnNeigh(const cv::Mat &neigh)
{
    double product = 1.0;
    cv::MatConstIterator_<uchar> iter = neigh.begin<uchar>();
    cv::MatConstIterator_<uchar> const end = neigh.end<uchar>();
    for (; iter != end; ++iter) 
        product *= *iter;
    return pow(product,1.0 / (neigh.rows * neigh.cols));
}

NOISE_ALGO_REGISTER("GeometricMeanFilter",GeometricMeanFilter);


